<?php
    $query="SELECT * FROM Zamowienie INNER JOIN Projekt WHERE Zamowienie.IdZamowienia = Projekt.IdZamowienia AND IdUmowy<>0 AND ukonczono=0";

    $wynik=mysql_query($query) or die('zapytanie niudane: '.mysql_error());

    echo "<form action=\"skrypty/realZamow/akcje/usZamow.php?login=$login\" method=\"post\">";
    echo "<table><tr>
				<td>Usuń</td>
                <td>Kwota</td>
                <td>Data Przyjęcia</td>
                <td>Projektant</td>
                <td>Klient</td>
                <td>Opis</td>
                <td>Zadządzaj</td>
			</tr>";

    while($line = mysql_fetch_array($wynik, MYSQL_NUM)){
            $adres = "skrypty/noweZamow/form/podglZamow.php?id={$line[0]}";
            $adres2 = "skrypty/realZamow/form/zarzadZamow.php?id=";
			echo "<tr>";
                echo "<td><input type=checkbox name=\"{$line[7]}\"></td>\n";
                echo "<td>{$line[2]}</td>\n";
                echo "<td>{$line[3]}</td>\n";

                if($line[4]!=0){
                    $query = "SELECT * FROM Projektant WHERE id={$line[4]}";
                    $tmp=mysql_query($query) or die('zapytanie niudane: '.mysql_error());
                    $tmp = mysql_fetch_row($tmp);
                    echo "<td>{$tmp[1]} {$tmp[2]}</td>\n";
                }else{
                    echo "<td>brak</td>\n";
                }

                $query = "SELECT * FROM Klient WHERE idKlienta={$line[5]}";
                $tmp=mysql_query($query) or die('zapytanie niudane: '.mysql_error());
                $tmp = mysql_fetch_row($tmp);
                if($tmp[10])
                    echo "<td>{$tmp[10]}</td>";
                else
                    echo "<td>{$tmp[1]} {$tmp[2]}</td>";

                $query = "SELECT * FROM Projekt WHERE idZamowienia={$line[0]}";
                $tmp=mysql_query($query) or die('zapytanie niudane: '.mysql_error());
                $tmp = mysql_fetch_row($tmp);
                $nr = $tmp[0];

                echo "<td><a target=\"_blank\" href=\"$adres\">treść</a></td>\n";
                echo "<td><a target=\"_blank\" href=\"$adres2$nr\">++</a></td>\n";


            echo "</tr>\n";
		}
        echo "</table>";
        echo "<input type=submit name=\"usun\" id=\"usun\" value=\"usuń\">";
        echo "</form>";



?>
